package com.ruoyi.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.business.domain.Rack;
import com.ruoyi.business.domain.RackParam;
import com.ruoyi.business.mapper.RackParamMapper;
import com.ruoyi.business.service.IRackParamService;
import com.ruoyi.business.vo.RackParamByIdVo;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 台架参数Service业务层处理
 * 
 * @author qiancheng
 * @date 2025-06-23
 */
@Service
public class RackParamServiceImpl extends ServiceImpl<RackParamMapper, RackParam> implements IRackParamService
{
    @Autowired
    private RackParamMapper rackParamMapper;
    @Autowired
    private RackServiceImpl rackService;

    /**
     * 查询台架参数
     * 
     * @param id 台架参数主键
     * @return 台架参数
     */
    @Override
    public RackParam selectRackParamById(Long id)
    {
        return rackParamMapper.selectRackParamById(id);
    }

    /**
     * 查询台架参数列表
     * 
     * @param rackParam 台架参数
     * @return 台架参数
     */
    @Override
    public List<RackParam> selectRackParamList(RackParam rackParam)
    {
        return rackParamMapper.selectRackParamList(rackParam);
    }

    /**
     * 新增台架参数
     * 
     * @param rackParam 台架参数
     * @return 结果
     */
    @Override
    public int insertRackParam(RackParam rackParam)
    {
        rackParam.setCreateTime(DateUtils.getNowDate());
        return rackParamMapper.insert(rackParam);
    }

    /**
     * 修改台架参数
     * 
     * @param rackParam 台架参数
     * @return 结果
     */
    @Override
    public int updateRackParam(RackParam rackParam)
    {
        rackParam.setUpdateTime(DateUtils.getNowDate());
        return rackParamMapper.updateRackParam(rackParam);
    }

    /**
     * 批量删除台架参数
     * 
     * @param ids 需要删除的台架参数主键
     * @return 结果
     */
    @Override
    public int deleteRackParamByIds(Long[] ids)
    {
        return rackParamMapper.deleteRackParamByIds(ids);
    }

    /**
     * 删除台架参数信息
     * 
     * @param id 台架参数主键
     * @return 结果
     */
    @Override
    public int deleteRackParamById(Long id)
    {
        return rackParamMapper.deleteRackParamById(id);
    }

    /**
     * 首页->>获取台架参数详细信息
     * @param rackParam
     * @return
     */
    @Override
    public RackParamByIdVo getRackParam(RackParam rackParam) {
        Rack rackById = rackService.getById(rackParam.getRackId());
        List<RackParam> paramList = rackParamMapper.getParamList(rackParam);
        return new RackParamByIdVo(rackById,paramList);
    }

}
